perm filename TESTC.SAI[1,JMC] blob sn#005231 filedate 1969-12-12 generic text, type T, neo UTF8
00100	comment A more sophisticated program to find numbers
00200	expressable as the sum of two cubes in more than one way.;
00300	
00400	begin integer m,n,t,max,l,b,c,d;
00500	integer procedure gcd(integer  i,  j);
00600	begin integer t; label a;
00700	if i>j then i ↔ j;
00800	a:
00900	if i=0 then return(j);
01000	t←j mod i; j←i; i←t;
01100	go to a end;
01200	outstr("
01300	b=");b←cvd(inchwl);outstr("
01400	");
01500	outstr("l="); l ← cvd(inchwl);
01600	
01700	begin integer array i[1:l],j[1:l]; label a, lose, r;
01800	for m←1 step 1 until l do i[m]←j[m]←0;
01900	m←1; max←l; i[2]←j[2]←1;c←1;
02000	
02100	a: c←c+1; m←m+1;
02200	if c>b then
02300	outstr(cvs(max)&" "&
02400	cvs(m)&" "&cvs(n)&" "&cvs(t)&" "&cvs(i[((m-1) mod l)+1])&" "&cvs(j[((m-1) mod l)+1])&"
02500	") ;
02700	if i[m]=0 then go to r;
02800	
02900	if j[m]<i[m] then
03000	begin
03100	n←i[m]↑3+(j[m]+1)↑3;
03200	if n>max+m-1 then go to lose;
03300	t←((n-1) mod l)+1;
03400	if i[t]  ≠ 0 and gcd(i[t],gcd(j[t],gcd(i[m],j[m]+1)))=1
03500	 then outstr(cvs(n)&" = "&cvs(i[t])&"↑3 + "&
03600	cvs(j[t])&"↑3 = "&cvs(i[m])&"↑3 + "&cvs(j[m]+1)&"↑3
03700	") 
03800	else begin i[t]←i[m]; j[t]←j[m]+1 end; 
03900	end;
04000	
04100	if j[m]=1 then begin n←(i[m]+1)↑3+1;
04200	if n>max+m-1 then go to lose;
04300	t←((n-1) mod l)+1;
04400	if i[t] ≠ 0 then outstr(cvs(n)&" = "&cvs(i[t])&"↑3 + "&
04500	cvs(j[t])&"↑3 = "&cvs(i[m]+1)&"↑3 + 1↑3
04600	")
04700	else begin i[t]←i[m]+1;j[t]←1 end; 
04800	end;
04900	i[m]←j[m]←0;
05000	r: if m=l then begin m←0; max←max+l end; go to a;
05100	lose:
05200	outstr("Out of storage.");
05300	outstr(cvs(max)&" "&cvs(m)&" "&cvs(n)&" "&cvs(t)&"
05400	");
05500	for m←1 step 1 until l do if i[m]≠0 then outstr(cvs(m)&" "&cvs(i[m])&
05600	" "&cvs(j[m])&"
05700	");
05800	end
05900	end;